<!-- 合作 -->
<template>
	<view class="bigBox">
		<view class="codeBigBox">
			<view class="codeBox" v-for="(item, index) in codeList" :key="item.id">
				<view class="codeBoxTitle">{{ titleName(item) }}</view>
				<view class="codeBoxdizi">{{ titleName2(item) }}</view>
				<view class="codeBoxneiron">{{ titleName3(item) }}</view>
				<view class="codeBoxnum">{{ titleName4(item) }}</view>
				<view class="codeBoxnum">{{ titleName5(item) }}</view>
				<view class="codeBoxBtn">
					<view class="btnBoxTwo" @tap="share(item)" style="margin-right: 10px;">{{ i18n.ctwfont50 }}</view>
					<view class="btnBox" @tap="seeBtn(item)">{{ i18n.ctwfont45 }}</view>
				</view>
				<view class="honLine" v-if="codeList.length != index + 1"></view>
			</view>
		</view>
		<view class="contactBg" :style="{bottom: isIOS ? '50px' : '84px' }"><image style="width: 100%; height: 100%;" src="/static/icon/superAnt/contactBg.png" mode=""></image></view>
	</view>
</template>

<script>
// import { toMapAPP } from '@/utils/goMapApps.js';
import { getStorage } from '@/utils/setStorage.js';
export default {
	props: ['codeList'],
	data: function() {
		return {
			topBarHeight: 0,
			windowHeight: 0
		};
	},
	onLoad() {},
	onUnload() {},
	onHide() {},
	destroyed() {},
	computed: {
		i18n() {
			return this.$t('businessCard');
		},
		isIOS() {
			if (uni.getSystemInfoSync().platform == 'android') {
				return true;
			} else {
				return false;
			}
		},
		titleName() {
			return function(val) {
				const languageFlag = getStorage('language') || 'th';
				let title = '';
				if (languageFlag === 'zh') {
					title = val.addressTitleCn;
				} else if (languageFlag === 'th') {
					title = val.addressTitleTh;
				} else {
					title = val.addressTitleEn;
				}
				return title;
			};
		},
		titleName2() {
			return function(val) {
				const languageFlag = getStorage('language') || 'th';
				let title = '';
				if (languageFlag === 'zh') {
					title = val.addressCn;
				} else if (languageFlag === 'th') {
					title = val.addressTh;
				} else {
					title = val.addressEn;
				}
				return title;
			};
		},
		titleName3() {
			return function(val) {
				const languageFlag = getStorage('language') || 'th';
				let title = '';
				if (languageFlag === 'zh') {
					title = val.contactWayCn;
				} else if (languageFlag === 'th') {
					title = val.contactWayTh;
				} else {
					title = val.contactWayEn;
				}
				return title;
			};
		},
		titleName4() {
			return function(val) {
				const languageFlag = getStorage('language') || 'th';
				let title = '';
				if (languageFlag === 'zh') {
					title = val.receiveTimeCn;
				} else if (languageFlag === 'th') {
					title = val.receiveTimeTh;
				} else {
					title = val.receiveTimeEn;
				}
				return title;
			};
		},
		titleName5() {
			return function(val) {
				const languageFlag = getStorage('language') || 'th';
				let title = '';
				if (languageFlag === 'zh') {
					title = val.markCn;
				} else if (languageFlag === 'th') {
					title = val.markTh;
				} else {
					title = val.markEn;
				}
				return title;
			};
		}
	},
	methods: {
		share(val) {
			const that = this;
			uni.setClipboardData({
				data: val.navigation,
				showToast: false,
				success: function() {
					uni.showToast({
						title: that.$t('businessCard').ctwfont51,
						icon: 'none',
						position: 'top'
					});
				},
				fail: function() {
					uni.showToast({
						title: that.$t('businessCard').ctwfont52,
						icon: 'none',
						position: 'top'
					});
				}
			});
		},
		// 预览图片
		seeBtn(val) {
			// toMapAPP(23.172769, 113.255228, this.$t('businessCard').ctwfont37);
			// 只能查看一张
			plus.nativeUI.previewImage([val.url]);
		}
	}
};
</script>

<style lang="scss" scoped>
.bigBox {
	// position: fixed;
	// height: 100%;
	width: 100%;
	padding: 20px;
	box-sizing: border-box;
	// background-color: #fbfbff;
	.codeBigBox {
		background-color: #fff;
		border-radius: 10px;
		box-shadow: 0 3px 5px 1px #e6e6e6;
		padding: 15px 0;
		.codeBox {
			padding: 0 15px;
			box-sizing: border-box;
			// margin-bottom: 15px;
			.codeBoxTitle {
				font-size: $uni-font-size-custom-e;
				font-weight: 700;
				color: #cd001b;
				margin-bottom: 10px;
			}
			.codeBoxdizi {
				font-size: $uni-font-size-custom-e;
				color: #424451;
				line-height: 16px;
				word-break: break-all; // 强制换行
			}
			.codeBoxneiron {
				font-size: $uni-font-size-custom-b;
				color: #424451;
				word-break: break-all; // 强制换行
			}
			.codeBoxnum {
				font-size: $uni-font-size-custom-b;
				color: #424451;
				word-break: break-all; // 强制换行
			}
			.codeBoxBtn {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 10px;
				.btnBox {
					padding: 2px 25px;
					border-radius: 20px;
					background-color: #cd001b;
					border: 1px solid #cd001b;
					color: #fff;
					font-size: $uni-font-size-custom-b;
				}
				.btnBoxTwo {
					padding: 2px 25px;
					border-radius: 20px;
					background-color: #f2f2f2;
					border: 1px solid #27397c;
					color: #27397c;
					font-size: $uni-font-size-custom-b;
				}
			}
			.honLine {
				border-top: 2px solid #fbbcc4;
				margin: 25px auto;
			}
		}
	}

	.contactBg {
		position: absolute;
		bottom: 50px;
		left: 0;
		width: 100%;
		height: 150px;
	}
}
</style>
